<?php
	class ItemAction extends CommonAction{
		
		public function index(){
			
			//分类目录列表
			$category=M('category',CommonModel);
			$catlist=$category->select();
			$this->assign('catlist',$catlist);
			//通知公告列表
			$notice=M('notice',CommonModel);
			$nolist=$notice->select();
			$this->assign('nolist',$nolist);
			//总结列表
			$item=M('item',CommonModel);
			$itemlist=$item->select();
			$this->assign('itemlist',$itemlist);
			//渲染模板
			$this->display('index');
			
		}
		
		public function show(){
			$item=M('item',CommonModel);
			$id=$_GET['id'];
			$item=$item->where("id=$id")->find();
			$this->assign('item',$item);
			$this->display('show');
			
		}
		
		public function add(){
			
			$this->display();
			
		}
		
		public function addok(){
			
			$item=M('item',CommonModel);
			$item->create();
			$item=$item->add();
			if($item){
				$this->assign("jumpUrl","__APP__/item/index");
				$this->assign("waitSecond",2);
				$this->success("添加日志成功！");
			}else{
				$this->error($item->getError());
			}
		}
		
		public function edit(){
			
			$item=M('item',CommonModel);
			$id=$_GET['id'];
			$item=$item->where("id=$id")->find();
			$this->assign('item',$item);
			$this->display();
		}
		
		public function editok(){
			
			$item=M('item',CommonModel);
			$item->create();
			$item=$item->save();
			if($item){
				$this->assign("jumpUrl","__APP__/item/index");
				$this->assign("waitSecond",2);
				$this->success("更新日志成功！");
			}else{
				$this->error($item->getError());
			}
		}
		
		public function del(){
			
			$item=M('item',CommonModel);
			$id=$_GET['id'];
			$item=$item->where("id=$id")->delete();
			if($item){
				$this->assign("jumpUrl","__APP__/item/index");
				$this->assign("waitSecond",2);
				$this->success("删除日志成功！");
			}else{
				$this->error($user->getError());
			}
		}
	}
